<template>
  <div>
    <header class="site-header jumbotron">
      <div class="container">
        <div class="row">
          <div class="col-xs-12">
            <h1>请发表对React的评论</h1>
          </div>
        </div>
      </div>
    </header>
    <div class="container">
      <Add :addComment="addComments"/>
      <List :comments="comments" :delCom="delComments"/> <!--组件间通信-->
    </div>
  </div>
</template>

<script>
import Add from './components/Add'
import List from './components/List'
export default {
  name: 'App',
  components: {
    Add,
    List
  },
  data () {
    return {
      comments: [
        {
          name: 'Bob',
          content: 'Vue还不错'
        },
        {
          name: 'Cat',
          content: 'Vue So Easy'
        },
        {
          name: 'Bz',
          content: 'Vue So So'
        }
      ]
    }
  },
  methods: {
    addComments (comment) {
      this.comments.unshift(comment)
    },
    delComments (index) {
      this.comments.splice(index, 1)
    }
  }
}
</script>

<style>
.reply {
  margin-top: 0px;
}

li {
  transition: .5s;
  overflow: hidden;
}

.handle {
  width: 40px;
  border: 1px solid #ccc;
  background: #fff;
  position: absolute;
  right: 10px;
  top: 1px;
  text-align: center;
}

.handle a {
  display: block;
  text-decoration: none;
}

.list-group-item .centence {
  padding: 0px 50px;
}

.user {
  font-size: 22px;
}
</style>
